package com.teamwork.ZuccEcho.Entity;

import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

////答卷
//@Entity
//@Table(name = "AnswerSheet", schema = "", catalog = "")
//public class AnswerSheet {
//    private long asId;//答卷ID
////    private long qnID;//对应的问卷ID
////    private String stuID;//答卷者ID
//    private List<Answer> answers;//学生的所有回答
//    private Date submitTime;//提交时间
//    private String asStatus;//问卷的状态（待修改，已提交）
//
//    @Id
//    @Column(name = "asId")
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    public long getAsId() {
//        return asId;
//    }
//
//    public void setAsId(long asId) {
//        this.asId = asId;
//    }
//
//    @Basic
//    @Column(name = "submitTime")
//    public Date getSubmitTime() {
//        return submitTime;
//    }
//
//    public void setSubmitTime(Date submitTime) {
//        this.submitTime = submitTime;
//    }
//
//    @Basic
//    @Column(name = "asStatus")
//    public String getAsStatus() {
//        return asStatus;
//    }
//
//    public void setAsStatus(String asStatus) {
//        this.asStatus = asStatus;
//    }
//
//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        AnswerSheet that = (AnswerSheet) o;
//        return asId == that.asId &&
//                Objects.equals(submitTime, that.submitTime) &&
//                Objects.equals(asStatus, that.asStatus);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(asId, submitTime, asStatus);
//    }
//}

//答卷
@Entity
//@Data
@Setter
@Getter
public class Answersheet {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long as_id;//答卷ID
    private Date as_submittime;//提交时间
    private String as_status;//问卷的状态（待修改，已提交）

    @ManyToOne
    @JoinColumn(name="qn_id",nullable=false)//在子表中的外键名
    private Questionnaire questionnaire;//问卷

//    @OneToMany()
    @OneToMany(mappedBy="answersheet")
//    @JoinColumn(name="as_id")//在子表中的外键名
    private List<Answer> answerList;

    @ManyToOne
    @JoinColumn(name="stu_id")//在子表中的外键名
    private Student student;//学生

    @Override
    public String toString() {
        return "Answersheet{" +
                "as_id=" + as_id +
                ", as_submittime=" + as_submittime +
                ", as_status='" + as_status + '\'' +
                '}';
    }
}